//
//  SearchTableViewCell.m
//  HimalayaMusic
//
//  Created by dllo on 16/1/13.
//  Copyright © 2016年 WXCLegendary. All rights reserved.
//

#import "SearchTableViewCell.h"

@implementation SearchTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.leftImage = [[UIImageView alloc] init];
        [self addSubview:self.leftImage];
        self.titleLabel = [[UILabel alloc] init];
        [self addSubview:self.titleLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.leftImage.frame = CGRectMake(5, 0, self.height, self.height);
    self.leftImage.layer.masksToBounds = YES;
    self.leftImage.layer.cornerRadius = self.height / 2;
    self.titleLabel.frame = CGRectMake(self.leftImage.right + 5, 0, self.width - self.leftImage.right - 10, self.height);
}

- (void)setAlbumModel:(AlbuModel *)albumModel {
    if (_albumModel != albumModel) {
        _albumModel = albumModel;
    }
    if (self.albumModel.cover_path == nil) {
        self.leftImage.image = [UIImage imageNamed:@"album"];
    } else {
        [self.leftImage sd_setImageWithURL:[NSURL URLWithString:self.albumModel.cover_path]];
        self.titleLabel.text = self.albumModel.title;
    }
    
    
}

- (void)setUserModel:(UserModel *)userModel {
    if (_userModel != userModel) {
        _userModel = userModel;
    }
    [self.leftImage sd_setImageWithURL:[NSURL URLWithString:self.userModel.smallPic]];
    self.titleLabel.text = self.userModel.nickname;

}

- (void)setTrackModel:(TrackModel *)trackModel {
    if (_trackModel != trackModel) {
        _trackModel = trackModel;
    }
    [self.leftImage sd_setImageWithURL:[NSURL URLWithString:self.trackModel.cover_path]];

    self.titleLabel.text = self.trackModel.title;
    
    
    
    
    
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
